<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="newtemplatesfiles5/img/favicon.html">

    <title>设置个人信息</title>

    <!-- Bootstrap core CSS -->
    <link href="newtemplatesfiles5/css/bootstrap.min.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="newtemplatesfiles5/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="newtemplatesfiles5/css/style.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="newtemplatesfiles5/js/html5shiv.js"></script>
    <script src="newtemplatesfiles5/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<section id="container" class="">

    <!--header start-->
    <div th:insert="common/schoolCounsellor-common-header::top"></div>
    <!--header end-->
    <!--sidebar start-->
    <div th:insert="common/schoolCounsellor-common-sidebar::#left"></div>
    <!--sidebar end-->
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
            <!-- page start-->
            <div class="row">
                <!--student-info-left  start-->
                <div th:insert="common/schoolCounsellor-info-left::#schoolCounsellor-info-left"></div>
                <!--student-info-left  end-->

                <aside class="profile-info col-lg-9">
                    <section class="panel">
                        <div class="bio-graph-heading">
                            <h2>修改个人信息</h2>
                        </div>
                        <div class="panel-body bio-graph-info">
                            <form class="form-horizontal" role="form" id="myForm">
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">工号</label>
                                    <div class="col-lg-6">
                                        <input name="schoolCounsellorID" disabled type="text" class="form-control" placeholder="" th:value="${session.schoolCounsellor.schoolCounsellorID}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">姓名</label>
                                    <div class="col-lg-6">
                                        <input name="name" disabled type="text" class="form-control" placeholder="" th:value="${session.schoolCounsellor.name}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">学校</label>
                                    <div class="col-lg-6">
                                        <input name="universityName" disabled type="text"  class="form-control" placeholder="" th:value="${session.schoolCounsellorImpl.universityName}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">学院</label>
                                    <div class="col-lg-6">
                                        <input name="departmentName" disabled type="text" class="form-control" placeholder="" th:value="${session.schoolCounsellorImpl.departmentName}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">专业</label>
                                    <div class="col-lg-6">
                                        <input name="majorName" type="text" disabled class="form-control" placeholder="" th:value="${session.schoolCounsellorImpl.majorName}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">邮箱</label>
                                    <div class="col-lg-6">
                                        <input name="email" type="text" class="form-control" placeholder="" th:value="${session.schoolCounsellorImpl.email}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">手机</label>
                                    <div class="col-lg-6">
                                        <input name="phoneNumber" type="text" class="form-control" placeholder="" th:value="${session.schoolCounsellorImpl.phoneNumber}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-lg-2 control-label">头像</label>
                                    <div class="col-lg-6">
                                        <img style="width: 60px" id="show" th:src="${session.schoolCounsellor.image}" alt=""><br>
                                        <input type="file" class="file-pos" id="myfile" name="image" onchange="showImage()">
                                    </div>
                                </div>

                            </form>
                            <div class="form-group">
                                <div class="col-lg-offset-2 col-lg-10">
                                    <button type="submit" class="btn btn-success" onclick="schoolCounsellorInfoSubmit()">保存</button>
                                </div>
                            </div>
                        </div>

                    </section>
                    <script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
                    <script type="text/javascript" src="js/jquery.min.js"></script>
                    <script src="asserts/js/popper.min.js"></script>
                    <script src="asserts/js/feather.min.js"></script>
                    <script src="asserts/js/bootstrap.min.js"></script>
                    <script type="text/javascript">
                        //图片回显
                        function showImage() {
                            var reader = new FileReader();
                            var file = document.getElementById("myfile").files[0];
                            console.log(file);
                            reader.onload=function (e) {
                                ///console.log(this.result);
                                document.getElementById('show').src=this.result;
                            };
                            reader.readAsDataURL(file);
                        }


                        function verifyLoginStatus() {
                            //验证登录状态
                            console.log("1");
                            var message = document.getElementById("mystatus").innerText;
                            console.log(message);
                            if(message == '请先登录'){
                                alert("请登录");
                                location.href="login";
                                return '1';
                            }
                            return '2';
                        }

                        //表单提交
                        function schoolCounsellorInfoSubmit() {

                            var status = verifyLoginStatus();

                            if(status == '2'){
                                var form = new FormData(document.getElementById("myForm"));

                                $.ajax({
                                    url:"schoolCounsellorFinishInfo.do",
                                    type:"post",
                                    dataType:"html",
                                    data:form,
                                    cache:false,
                                    processData:false,
                                    contentType:false,
                                    success: function (data) {
                                        if(data=="success"){
                                            alert("修改成功！");
                                            location.href="newSchoolCounsellorFinishInfo";
                                        }else{
                                            alert("修改失败!");
                                        }
                                    },
                                    error:function (data) {
                                        console.log("error");
                                        alert("修改失败!");
                                    }
                                })
                            }

                        }
                    </script>
                </aside>
            </div>

            <!-- page end-->
        </section>
    </section>
    <!--main content end-->
</section>

<!-- js placed at the end of the document so the pages load faster -->
<script src="newtemplatesfiles5/js/jquery.js"></script>
<script src="newtemplatesfiles5/js/bootstrap.min.js"></script>
<script src="newtemplatesfiles5/js/jquery.scrollTo.min.js"></script>
<script src="newtemplatesfiles5/js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="newtemplatesfiles5/assets/jquery-knob/js/jquery.knob.js"></script>

<!--common script for all pages-->
<script src="newtemplatesfiles5/js/common-scripts.js"></script>


</body>
</html>
